import os

import command


def git_branch_select():
    output = os.popen('git branch').read()
    split = output.split("\n")
    branchs = []
    for index, branch in enumerate(split):
        if len(branch.strip()) > 0:
            print(index + 1, branch.strip())
            branch_strip__replace = branch.strip().replace("*", '')
            branchs.append(branch_strip__replace)
    user_input = input("Please select branch number: ")
    selected_branch = branchs[int(user_input) - 1]
    command_line = "git checkout %s" % selected_branch
    command.exe_command(command_line)


if __name__ == '__main__':
    git_branch_select()
